package org.compression.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 
@Configuration
public class ApplicationConfig extends WebMvcConfigurerAdapter {
	


	@Value("${file.path}")
	public String filepath;

	@Value("${file.pathImage}")
	public String pathImage;
	
	
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
	//文件映射
		
		 String os = System.getProperty("os.name");
	     if (os.toLowerCase().startsWith("win")) {  //如果是Windows系统
	        registry.addResourceHandler("/filepath/**").
	      //    addResourceLocations("file:D:/uploadBaseDir/productPic/");
	     //   addResourceLocations("file:D:/00_Driver/04_HP/Tool_SoftpaqSOP/Gamora/ML01_Chipset 10.1.17541.8066/SP87502/");
	    
	        addResourceLocations("file:"+filepath);
	        
	        registry.addResourceHandler("/pathImage/**").
		      //    addResourceLocations("file:D:/uploadBaseDir/productPic/");
		     //   addResourceLocations("file:D:/00_Driver/04_HP/Tool_SoftpaqSOP/Gamora/ML01_Chipset 10.1.17541.8066/SP87502/");
		    
		        addResourceLocations("file:"+pathImage);
	        
	        
	        
	        
	     
	     }else{//linux和mac系统
	      /*  registry.addResourceHandler("/productPic/**").
	         // addResourceLocations("file:/uploadBaseDir/productPic/");
	        
	        addResourceLocations("file:"+filepath);
	        */
	        
	        
	        
	        registry.addResourceHandler("/filepath/**").
		      //    addResourceLocations("file:D:/uploadBaseDir/productPic/");
		     //   addResourceLocations("file:D:/00_Driver/04_HP/Tool_SoftpaqSOP/Gamora/ML01_Chipset 10.1.17541.8066/SP87502/");
		    
		        addResourceLocations("file:"+filepath);
		        
		        registry.addResourceHandler("/pathImage/**").
			      //    addResourceLocations("file:D:/uploadBaseDir/productPic/");
			     //   addResourceLocations("file:D:/00_Driver/04_HP/Tool_SoftpaqSOP/Gamora/ML01_Chipset 10.1.17541.8066/SP87502/");
			    
			        addResourceLocations("file:"+pathImage);
		        
		        
	        
	        
	        
	        
	        
	        
	        
	        
	     }
	     super.addResourceHandlers(registry);
	   } 
		
		
		
	
	

	
}